//
//  HMUserAccount.swift
//  sina
//
//  Created by Kent on 16/9/26.
//  Copyright © 2016年 Ming. All rights reserved.
//

import UIKit

class HMUserAccount: NSObject, NSCoding {

    //2.00c1qxIG5LyW_B3f017410a30AZKdh
    var access_token: String?
    
    var expires_in: Int = 0 {
        didSet {
            expired_date = Date(timeIntervalSinceNow: Double(expires_in))
        }
    }
    
    var expired_date: Date?
    
    var uid: String?
    
    // 用户名
    var name: String?
    
    //头像 180 180
    var avatar_large: String?
    
    init(dict: [String : Any]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
 
    func encode(with aCoder: NSCoder) {
        aCoder.encode(access_token, forKey: "access_token")
        aCoder.encode(uid, forKey: "uid")
        aCoder.encode(name, forKey: "name")
        aCoder.encode(avatar_large, forKey: "avatar_large")
        aCoder.encode(expired_date, forKey: "expired_date")
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        access_token = aDecoder.decodeObject(forKey: "access_token") as? String
        uid = aDecoder.decodeObject(forKey: "uid") as? String
        name = aDecoder.decodeObject(forKey: "name") as? String
        avatar_large = aDecoder.decodeObject(forKey: "avatar_large") as? String
        expired_date = aDecoder.decodeObject(forKey: "expired_date") as? Date
        
    }
    
}





















